using System;
using System.Collections.Generic;
using System.Text;
using AllegNet;

namespace DemonHunter
{
    class Explosion:Entity
    {
        //data
        private static List<Bmp> bitmaps;
        private int curBitmap = 0;

        private bool timerStarted = false;
        private DateTime start;

        //constructor
        public Explosion()
        {
        }
        //overridden functions
        public override void move() 
        {

        }

        /// <summary>
        /// not necessary
        /// </summary>
        public override void animate()
        {
            if (timerStarted == false)
            {
                start = DateTime.Now;
                timerStarted = true;
            }

            DateTime stop = DateTime.Now;
            TimeSpan elapsed = stop - start;

            if (elapsed.Milliseconds > 25) curBitmap = 1;
            if (elapsed.Milliseconds > 50) curBitmap = 2;
            if (elapsed.Milliseconds > 100) Level.GetInstance().RemoveEntity(this);
        }

        public override Bmp GetCurrentBitmap()
        {
            return bitmaps[curBitmap];
        }
        /// <summary>
        /// load bitmaps into memory
        /// </summary>
        public new static void LoadBitmaps()
        {
            bitmaps = new List<Bmp>();
            bitmaps.Add(Game.GetInstance().LoadBitmap("C:\\DemonHunterart\\props\\explosion3.bmp"));
            bitmaps.Add(Game.GetInstance().LoadBitmap("C:\\DemonHunterart\\props\\explosion2.bmp"));
            bitmaps.Add(Game.GetInstance().LoadBitmap("C:\\DemonHunterart\\props\\explosion1.bmp"));
        }
        /// <summary>
        /// return current bitmap height
        /// </summary>
        /// <returns></returns>
        public override double GetCurrentBitmapHeight()
        {
            return bitmaps[curBitmap].Height;
        }
    }
}
